<?php

class CI_Creinputdate{
	var $inputid = 'date';
	var $inputvalue = '';
	var $inputclass = 'inputDate';
	var $inputformat = 'dd-mm-yy';
	var $inputmin = -11365;
	var $inputmax = 11365;
	var $inputmonth = 1;
	var $html = '';
	function _geninputDate($detail=null){
		$this->html = '';
		if(is_array($detail)){
			foreach($detail as $k => $v){
				$this->$k = $v;
			}
		} 
		   // 
		$this->html = '
					<input typed="input" name="'.$this->inputid.'" id="'.$this->inputid.'" value="'.$this->inputvalue.'" class="'.$this->inputclass.'" readonly="readonly" />
					<script type="text/javascript" language="javascript">
					$(document).ready(function(){	
						$("#'.$this->inputid.'").datepicker({
							dateFormat: "'.$this->inputformat.'",
							yearOffset: 0,
							minDate: '.$this->inputmin.', 
							maxDate: '.$this->inputmax.',
							showOn: "button", buttonImage: "'.URLPATH_IMAGES.'icons/calendar.gif", 
							buttonImageOnly: true,
							showButtonPanel: false,

							numberOfMonths: '.$this->inputmonth.',
							
							changeYear: true,
							changeMonth: true
						});
					});
					</script>';
		return $this->html;
	}

	/*
	* -------------------------------------------------------
	* เธชเธฃเนเธฒเธเธเธฅเนเธญเธเธเธฑเธ”เธเธฒเธฃเธเนเธญเธกเธนเธฅเธงเธฑเธเธ—เธตเนเนเธเธเธเนเธงเธ
	* -------------------------------------------------------
	*/
	
	function getInputDateLenght(){
	
		$this->html='
		<input typed="input" name="'.$this->inputidStart.'" id="'.$this->inputidStart.'" size="12" value="'.$this->inputvalueStart.'" class="'.$this->inputclass.'" />
		&nbsp;'.$this->inputLengLabel.'
		<input typed="input" name="'.$this->inputidFinish.'" id="'.$this->inputidFinish.'" size="12" value="'.$this->inputvalueFinish.'" class="'.$this->inputclass.'" />
		<script type="text/javascript" language="javascript">
		$(document).ready(function(){
			$(function()
			{
				$("#'.$this->inputidStart.'").datepicker({
				dateFormat: \'dd-mm-yy\',
				yearOffset: 0,
				minDate: '.$this->inputmin.', 
				maxDate: '.$this->inputmax.',
				showOn: "button", buttonImage: "'.URLPATH_IMAGES.'icons/calendar.gif", buttonImageOnly: true,
				numberOfMonths: '.$this->inputmonth.',
				showButtonPanel: false,
				onSelect: function() 
				{ 
					var TDate	= $(this).val();
					Temp		= TDate.split(\'-\');
					var CDate	= Temp[1]+\'/\'+Temp[0]+\'/\'+Temp[2];
					CDate		= new Date(CDate);
					CDate.setDate(CDate.getDate()+0);
					$(\'#'.$this->inputidFinish.'\').datepicker(\'option\', \'minDate\',TDate); 
				}
				});

				$("#'.$this->inputidFinish.'").datepicker({
					dateFormat: \'dd-mm-yy\',
					yearOffset: 0,
					minDate: parseInt('.$this->inputmin.')+0,
					maxDate: '.$this->inputmax.',
					showOn: "button", buttonImage: "'.URLPATH_IMAGES.'icons/calendar.gif", buttonImageOnly: true,
					numberOfMonths: '.$this->inputmonth.',
					showButtonPanel: false,
					onSelect: function() 
					{ 
						var TDate	= $(this).val()
						Temp		= TDate.split(\'-\');
						var CDate	= Temp[1]+\'/\'+Temp[0]+\'/\'+Temp[2];
						CDate		= new Date(CDate);
						CDate.setDate(CDate.getDate()-0);
						$(\'#'.$this->inputidStart.'\').datepicker(\'option\', \'maxDate\',CDate);	
					}	
				});
			});
			});
			</script>';
			return $this->html;
	}

}

?>